/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#ifndef XF_MATHHELPER
#define XF_MATHHELPER

#include <math.h>
#include "../XFrameworkTypedefsAndDefines.h"

#define RAD 0.017453292519943295769236907684886//chris
#define DEG 57.295779513082320876798154814105//chris

namespace XF
{
	class MathHelper
	{
	public:
		static inline float Pi(){return 3.14159265f;}
		static inline float TwoPi(){return 6.28318531f;}
		static inline float PiOver2(){return 1.57079633f;}
		static inline float PiOver4(){return 0.785398163f;}
		static float Infinity(){return 9e9f;}
		static inline float RadConversion(){return 0.017453292519943295769236907684886f;}
		static inline float DegConversion(){return 57.295779513082320876798154814105f;}
	
		static inline float Lerp(float value1, float value2, float amount)
		{
			return(value1 + ((value2 - value1) * amount));
		}
		static inline Vector3 VectorLerp(Vector3 value1, Vector3 value2, float amount) //chris
		{
			return(value1 + ((value2 - value1) * amount));
		}

		static inline float Min(float val1, float val2)
		{
			return ((val1 < val2) ? val1 : val2);
		}

		static inline float Max(float val1, float val2)
		{
			return ((val1 > val2) ? val1 : val2);
		}

		static inline void Clamp(float &clampVal, float min, float max)
		{
			clampVal = Min(clampVal, max);
			clampVal = Max(clampVal, min);
		}

		static inline float DegToRad(float value){return value * RadConversion();}
		static inline float RadToDeg(float value){return value * DegConversion();}

        static float Sqr(float num){return num * num;}

        static float Determinant(const XF::Vector2& p, const XF::Vector2& q)
        {
                return p.x * q.y - p.y * q.x;
		}
		//Chris thought i'd add these two functions:
		static bool IsOdd(int number) 
		{
			return (number & 0x1);
		}
		static bool IsEven(int number)
		{
			return (!(number & 0x1));
		}
	};
}

#endif